package com.shujia.java.day10.demo2;

public abstract class Pet implements PetImpl {
    private String name;
    private int health;

    public Pet() {
    }

    public Pet(String name, int health) {
        this.name = name;
        this.health = health;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHealth() {
        return health;
    }


    //健康值不能大于100 不能为负数 在<=40提示 需要增加健康值 快死了
    public void setHealth(int health) {
        if(health<=0){
            this.health=0;
            System.out.println("您的宠物挂了");
        }else if (health <= 40) {
            System.out.println("需要增加健康值 快死了");
        }

        if (health > 100) {
            this.health = 100;
            System.out.println("健康值以满，无法增加");
        } else {
            this.health = health;
        }
    }

}
